home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Type casting
- Date: 28 Feb 1996 08:26:05 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4h1vmtINNlte@anvil.ugrad.cs.ubc.ca>
- References: <4gfnmi$gsc@calvin.risq.qc.ca> <4gim30INNo4b@keats.ugrad.cs.ubc.ca> <4gkki1$a7c@charm.il.ft.hse.nl> <825460516snz@genesis.demon.co.uk>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <825460516snz@genesis.demon.co.uk>,
- Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
- >In article <4gkki1$a7c@charm.il.ft.hse.nl> robert@il.ft.hse.nl "robert" writes:
- >
- >>c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku):
- >> >In article <4gfnmi$gsc@calvin.risq.qc.ca>,
- >> >Pierre Coulombe <pcoulomb@criq.qc.ca> wrote:
- >> >> char string[80];
- >> >> strcpy(string, "25.4");
- >> >Try char *string = "25.4". This is a waste.
- >> >> sprintf(string, "%f", (float) atof(string) * MM_TO_UNITS);
- >> ^^^^^^
- >>It's not a waste, you can't be certain the result will fit in the 4
- >>chars.
-
- But with my suggestion it will try to write to a literal, which is illegal, so
- it is irrelevant whether or not there is room. :)
-
- >It also tries to write to a string literal which is illegal.
-
- Right, I did not notice that he was reading and writing from and to the same
- string.
- --
-
-